package com.rutong.study;

import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.MutableLiveData;

public class MainActivity extends AppCompatActivity {

    private MutableLiveData<String> data = new MutableLiveData();
    private MyLiveData timeData = new MyLiveData();

    private Button button;
    private TextView tv_count;
    private TextView time;
    private EditText editText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        button = findViewById(R.id.button);
        tv_count = findViewById(R.id.tv_count);
        time = findViewById(R.id.time);
        editText = findViewById(R.id.editText);

        data.observe(this, s -> tv_count.setText(s));
        button.setOnClickListener(v -> data.setValue(editText.getText().toString()));

        timeData.observe(this, s -> time.setText(s));

    }
}
